import request from '@/utils/request'

const userApi = {
  userList: '/boss/system/user/list',
  userAdd: '/boss/system/user/add',
  userAddFast: '/boss/project/team/addAdmin',
  userUpdate: '/boss/system/user/update',
  joinProject: '/boss/project/info/join',
  userImport: '/boss/system/user/import',
  userExport: '/boss/system/user/export',
  switchStatus: '/boss/system/user/status/update',
  updatePassword: '/boss/system/user/pwd/update',
  list: '/common/listOrgInfo',
  orgList: '/boss/org/info/listOrg',
  areaList: '/common/listOrgAreaInfo',
  rolesList: '/boss/system/role/list',
  resetPwd: '/boss/system/user/pwd/reset'
}

export function getRolesList (parameter) {
  return request({
      url: userApi.rolesList,
      method: 'post',
      data: parameter
  })
}
// 加入项目
export function joinProject (parameter) {
  return request({
      url: userApi.joinProject,
      method: 'post',
      data: parameter
  })
}
export function getUserList (parameter) {
  return request({
    url: userApi.userList,
    method: 'post',
    data: parameter
  })
}

export function addUser (parameter) {
  return request({
    url: userApi.userAdd,
    method: 'post',
    data: parameter
  })
}

export function addUserFast (parameter) {
  return request({
    url: userApi.userAddFast,
    method: 'post',
    data: parameter
  })
}

export function updateUser (parameter) {
    return request({
      url: userApi.userUpdate,
      method: 'post',
      data: parameter
    })
  }

export function getOrgList (parameter) {
    return request({
      url: userApi.list,
      method: 'post',
      data: parameter
    })
  }
export function getSponsorList (parameter) {
    return request({
      url: userApi.orgList,
      method: 'post',
      data: parameter
    })
  }
  export function getAreaList (parameter) {
    return request({
      url: userApi.areaList,
      method: 'post',
      data: parameter
    })
  }
  export function switchStatus (parameter) {
    return request({
      url: userApi.switchStatus,
      method: 'post',
      data: parameter
    })
  }
// 个人中心修改密码
export function updatePassword (parameter) {
  return request({
    url: userApi.updatePassword,
    method: 'post',
    data: parameter
  })
}

  // 账号导入
export function userImport (parameter) {
  return request({
    url: userApi.userImport,
    method: 'post',
    data: parameter,
    headers: { 'Content-Type': 'multipart/form-data' }
  })
}

export function userExport (parameter) {
  return request({
    url: userApi.userExport,
    method: 'get',
    params: parameter,
    responseType: 'blob'
  })
}

// 重置密码
export function resetPwd (parameter) {
  return request({
    url: userApi.resetPwd,
    method: 'post',
    data: parameter
  })
}
